<?php

include("header.php");
if(isset($_GET["restoid"])&& isset($_GET["nationid"])&& isset($_GET["typeid"])){
	$restoid=$_GET["restoid"];
	$nationid=$_GET["nationid"];
	$typeid=$_GET["typeid"];
}else{
	redirect("index.php");
}
?>
<div class="contactBg">
<form id="mainform" action="">
	<?php

	// Connect to server and select databse.
	$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
	$db->connect();

	$nationsql="SELECT nation_name.NATION_NAME_$_lang AS nation FROM nation_name WHERE nation_name.NATION_ID =$nationid";
	$typesql="SELECT type_resto.TYPE_NAME_$_lang AS type FROM type_resto WHERE type_resto.TYPE_ID=$typeid";
	$restonamesql="SELECT info_resto.RESTO_NAME_$_lang AS restoname FROM info_resto WHERE info_resto.RESTO_ID=$restoid";
	$sql = "SELECT info_resto.RESTO_NAME_$_lang AS restoname, info_resto.RESTO_INTRO_$_lang AS resto_intro,
	info_resto.RESTO_ADDR AS resto_addr, info_resto.RESTO_MAIL as mail, info_resto.RESTO_TIME_$_lang as time,
	info_resto.RESTO_TEL as tel, info_resto.RESTO_REDU as reduc,info_resto.REDU_STR as redu_str, info_resto.HAS_COUPON as has_coupon, info_resto.HAS_RESERV as has_reserv, 
	info_resto.INTRO_PIC as intro_pic, info_resto.RESTO_WEBSITE as site FROM info_resto WHERE info_resto.RESTO_ID=$restoid";
	$imagesql="SELECT resto_pic.PIC_LOCATION as pic, resto_pic.INTRO_$_lang as intro FROM resto_pic WHERE resto_pic.RESTO_ID=$restoid";
	
	$rs_result = $db->query_first($sql);
	$nation = $db->query_first ($nationsql);
	$type = $db->query_first($typesql);
	$restoname=$db->query_first($restonamesql);
	$images=mysql_query($imagesql);
	
	$rs_count_result = $db->query_first ("SELECT COUNT(RESTO_ID) FROM info_resto WHERE info_resto.RESTO_TYPE_ID =$typeid AND info_resto.RESTO_NATION =$nationid");
	$countorder= $db->query_first("SELECT COUNT(ID) as num FROM order_info where restoid=".$restoid);
	//get each values
	$site=$rs_result['site'];
	$resto_intro=$rs_result['resto_intro'];
	$resto_addr=$rs_result['resto_addr'];
	$mail=$rs_result['mail'];
	$time=$rs_result['time'];
	$tel=$rs_result['tel'];
	$redu=$rs_result['reduc'];
	$redu_str=$rs_result['redu_str'];
	$has_coupon=ord($rs_result['has_coupon']);
	$has_reserv=ord($rs_result['has_reserv']);
	$intro_pic=$rs_result['intro_pic'];
	$totalorder=$countorder['num'];
	

	
	// Check result
	// This shows the actual query sent to MySQL, and the error. Useful for debugging.
	if (!$rs_result) {
		$message  = 'Invalid query: ' . mysql_error() . "\n";
		$message .= 'Whole query: ' . $sql;
		die($message);
	}
	$db->close();
	?>
  <div class="contact">
    <ul>
    <?php if($_lang==FR){?>
      <li><?php if($_lang==FR){ echo "Accueil";} else if($_lang==ARB){echo "الصفحة الرئيسية";}?>></li>
      <li><?php echo $nation['nation']; ?>></li>
      <li><?php echo $type['type']; ?>></li>
      <li><?php echo $restoname['restoname']; ?></li>
     <?php }else{?>
      <li><?php echo $restoname['restoname']; ?></li>
      <li><<?php echo $type['type']; ?></li>
      <li><<?php echo $nation['nation']; ?></li>
      <li><<?php if($_lang==FR){ echo "Accueil";} else if($_lang==ARB){echo "الصفحة الرئيسية";}?></li>
     <?php }?>
    </ul>
  </div>
  <!--contact end of-->
  
  <div  class="dining">
    <div class="diningLeft fl">
      <dl>
        <h5><?php echo $restoname['restoname']; ?> </h5>
        <dt><?php echo $resto_addr; ?></dt>
        <dd><a href="#" onclick="javascript:window.open('map/phpsqlajax_map_v3.php?restoid=<?php echo $restoid; ?>','map','width=525,height=325,left=200,top=100');");"><i></i><?php if($_lang==FR){ echo "Voir le plan";} else if($_lang==ARB){echo "الخريطة";}?> >></a></dd>
        <?php if($has_reserv){?>
		<dd><p class="fl"><a href="reserver.php?restoid=<?php echo $restoid; ?>" class="reserver144"></a></p><p class="fl"><?php if($redu!='0'){?><strong>-<?php echo $redu; ?>%</strong><br/><?php }?><?php if($redu!='0'){ echo $redu_str; }?></p></dd>
        <?php }else if($_lang==FR){?>
        <dd><a style="width:142px; height:44px; display:inline-block; margin:0 10px 5px 0"><img src="/images/reserver1.png" ></a></dd>
        <?php }else {?>
        <dd><a style="width:142px; height:44px; display:inline-block; margin:0 10px 5px 0"><img src="/images/reserver1-arabe.png"></a></dd>
        <?php }?>
		<?php if($has_coupon){?>
		<dd><a href="coupon.php?restoid=<?php echo $restoid; ?>" class="coupon144"></a></dd>
		<?php }else if($_lang==FR){?>
        <dd><a style="width:142px; height:44px; display:inline-block; margin:0 10px 5px 0"><img src="/images/coupon1.png"></a></dd>
        <?php }else {?>
        <dd><a style="width:142px; height:44px; display:inline-block; margin:0 10px 5px 0"><img src="/images/coupon1-arabe.png"></a></dd>
        <?php }?>
      </dl>
      <ul>
        <li><code class="timeIcon"></code><?php if(strlen($time)>=36) {echo substr($time,0,36);}else {echo substr($time,0,strlen($time));} ?></li>
        <li style="padding-left:30px; margin-bottom:5px"><?php if(strlen($time)>36) {echo substr($time,36);}else {echo " ";} ?></li>
        <li class="bottom20"><code class="website"></code><a href="http://<?php echo $site; ?>">Site Web</a></li>
        <?php if($_lang==FR){?>
        <li><b><?php echo $totalorder; if($_lang==FR){ echo " per. ont déjà reservé";} else if($_lang==ARB){echo " حجزحتى ألأن";}?></b></li>
        <?php }else{?>
        <li><table><tr><td><b> حجزحتى ألأن </b></td><td><b>&nbsp;&nbsp;<?= $totalorder?> </b></td></tr></table></li>
        <?php }?>
      </ul>
    </div>
    <!--diningLeft end of-->
    <div class="diningRight fr">
        <div id="container">
          <div class="flexslider">
            <ul class="slides">
			<?php
					while ($row = mysql_fetch_assoc($images)) {
			?>
                <li>
                    <img src="<?php echo $row['pic'];?>" width="570" height="270"/>
                    <p class="flex-caption"><?php echo $row['intro'];?></p>
                </li>
             <?php
				};
			?>
            </ul>
        </div>
      </div>
      <!--container end of--> 
    </div>
    <!--diningRight end of-->
  </div>
  <!--dining end of-->
  <div class="diningContent">
         <?php if($_lang==FR){ echo "<h3> Présentation </h3>";} else if($_lang==ARB){echo "<h3 style='text-align:right;'> مقدمة</h3>";}?>
         <ul>
          <li><?php echo $resto_intro;?></li>
         </ul>
      </div>
       <!--diningContent end of-->
    </form>
</div>  
<!--contactBg end of-->
<script type="text/javascript" src="js/jquery-1.4.min.js"></script>
<script type="text/javascript" src="js/jquery.flexslider-min.js"></script>
<script type="text/javascript">
  $(window).load(function() {
	  $('.flexslider').flexslider({
		  slideshowSpeed: 3000,
		  pauseOnHover: true,
		  });
  });
$(function() {
$("#login").hover(
  function () {
	$(".loginDl").show();
  },
  function () {
	$(".loginDl").hide();
  }
);
});
</script>
<?php
include("foot.php");
?>
